<template>
    <div class="card card-custom">
      <div class="card-body p-0">
        <!--begin: Wizard-->
        <div
          class="wizard wizard-3"
          id="kt_wizard_v3"
          data-wizard-state="step-first"
          data-wizard-clickable="true"
        >
          <!--begin: Wizard Nav -->
          <div class="wizard-nav border-bottom mb-1 mb-lg-5">
            <div class="wizard-steps px-8 py-8 px-lg-15 py-lg-3">
              <div
                class="wizard-step"
                data-wizard-type="step"
                data-wizard-state="current"
              >
                <div class="wizard-label">
                  <h3 class="wizard-title"><span>1</span> 输入角色模型</h3>
                  <div class="wizard-bar"></div>
                </div>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <h3 class="wizard-title"><span>2</span> 输入用例模型</h3>
                  <div class="wizard-bar"></div>
                </div>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <h3 class="wizard-title"><span>3</span> 计算技术复杂因子TCF</h3>
                  <div class="wizard-bar"></div>
                </div>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <h3 class="wizard-title"><span>4</span> 计算环境因子EF</h3>
                  <div class="wizard-bar"></div>
                </div>
              </div>
              <div class="wizard-step" data-wizard-type="step">
                <div class="wizard-label">
                  <h3 class="wizard-title"><span>5</span> 计算调整后的用例点</h3>
                  <div class="wizard-bar"></div>
                </div>
              </div>
            </div>
          </div>
          <!--end: Wizard Nav -->
  
          <!--begin: Wizard Body-->
          <div class="row justify-content-center py-12 px-8 py-lg-15 px-lg-10">
            <div class="col-xl-12 col-xxl-7">
              <!--begin: Wizard Form-->
              <form class="form" id="kt_form">
                <!--begin: Wizard Step 1-->
                <div
                  class="pb-5"
                  data-wizard-type="step-content"
                  data-wizard-state="current"
                >
                  <h3 class="mb-10 font-weight-bold text-dark">
                    Input Actor Model                
                  </h3>
                  <div class="form-group">
                    <label>enter file</label>
              <div>
                <!-- Styled -->
                <b-form-file
                  v-model="file"
                  :state="Boolean(file)"
                  placeholder="Choose a Xml file or drop it here..."
                  drop-placeholder="Drop file here..."
                ></b-form-file>
                <div class="mt-3">Selected file: {{ file ? file.name : "" }}</div>
              </div>
              <div>
             </div>
                  </div>
                  <div class="form-group">
                    <div>
                     <label>加权功能点展示</label>
                     <!-- 点击按钮,获取文件Xml格式的file对象,调用函数读取文件内容并存储到变量中,并在表单里渲染 -->
                     <b-col lg="4" class="pb-2">
                        <b-button @click="OnShow()" size="sm">Show </b-button>
                     </b-col>                  
                   </div>
                    <div>
                      <b-table striped hover :items="item"></b-table>
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div class="font-weight-bold mb-3">
                      UAW:
                    </div>
                    <div class="line-height-md">
                      Simple Actor:{{AccountForActorNumber().Simple}}
                      <br />
                      Common Actor:{{AccountForActorNumber().Common}} <br />
                      Complex Actor:{{AccountForActorNumber().Complex}}<br />
                      UAW=3*{{AccountForActorNumber().Complex}}+2*{{AccountForActorNumber().Common}}+1*{{AccountForActorNumber().Simple}}={{calculateUAW()}}
                    </div>
          </div>
                <!--end: Wizard Step 1-->
  
                <!--begin: Wizard Step 2-->
                <div
                  class="pb-5"
                  data-wizard-type="step-content"
                  data-wizard-state="current"
                >
                  <h3 class="mb-10 font-weight-bold text-dark">
                    Input UseCase Model
                  </h3>
                  <div class="form-group">
                    <label>enter file</label>
              <div>
                <!-- Styled -->
                <b-form-file
                  v-model="file2"
                  :state="Boolean(file2)"
                  placeholder="Choose a Xml file or drop it here..."
                  drop-placeholder="Drop file here..."
                ></b-form-file>
                <div class="mt-3">Selected file: {{ file2 ? file2.name : "" }}</div>
              </div>
              <div>
             </div>
                  </div>
                  <div class="form-group">
                    <div>
                     <label>加权功能点展示</label>
                     <!-- 点击按钮,获取文件Xml格式的file对象,调用函数读取文件内容并存储到变量中,并在表单里渲染 -->
                     <b-col lg="4" class="pb-2">
                        <b-button @click="OnShow2()" size="sm">Show </b-button>
                     </b-col>                  
                   </div>
                    <div>
                      <b-table striped hover :items="item2"></b-table>
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div class="font-weight-bold mb-3">
                      UUC:
                    </div>
                    <div class="line-height-md">
                      Simple Use Case:{{AccountForUseCaseNumber().Simple}}
                      <br />
                      Common Use Case:{{AccountForUseCaseNumber().Common}} <br />
                      Complex Use Case:{{AccountForUseCaseNumber().Complex}}<br />
                      UUC=15*{{AccountForUseCaseNumber().Complex}}+10*{{AccountForUseCaseNumber().Common}}+5*{{AccountForUseCaseNumber().Simple}}={{calculateUUC()}}<br/>
                      UUCP=UAW+UUC={{calculateUAW()+calculateUUC()}}
                    </div>
          </div>
                <!--end: Wizard Step 2-->
  
                <!--begin: Wizard Step 3-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Calculate the technical complexity factor                
                  </h4>
                  <div class="form-group">
                    <label>Distributed System(Weight:2)</label>
                    <select
                      name="T1"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T1"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Response or Throughout Performance(Weight:1)</label>
                    <select
                      name="T2"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T2"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>End-user efficient(Weight:1)</label>
                    <select
                      name="T3"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T3"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label> Complex intemal processing(Weight:1)</label>
                    <select
                      name="T4"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T4"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Code must be reusable(Weight:1)</label>
                    <select
                      name="T5"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T5"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Easy to install(Weight:0.5)</label>
                    <select
                      name="T6"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T6"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Easy to use(Weight:0.5)</label>
                    <select
                      name="T7"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T7"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Portable(Weight:2)</label>
                    <select
                      name="T8"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T8"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Easy to change(Weight:1)</label>
                    <select
                      name="T9"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T9"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Concument(Weight:1)</label>
                    <select
                      name="T10"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T10"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Indudes special secunty feature(Weight:1)</label>
                    <select
                      name="T11"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T11"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Provides direct access for third party(Weight:1)</label>
                    <select
                      name="T12"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T12"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>Special user training facilities requied(Weight:1)</label>
                    <select
                      name="T13"
                      class="form-control form-control-solid form-control-lg"
                      v-model="T13"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div class="font-weight-bold mb-3">
                      TCF:
                    </div>
                    <div class="line-height-md">
                      TFactor:{{calculateTFactor()}}
                      <br />
                      TCF=0.6+(0.01*TFactor)={{calculateTCF()}}
                    </div>
                </div>
                <!--end: Wizard Step 3-->
  
                <!--begin: Wizard Step 4-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Calculate environmental factors                
                  </h4>
                  <div class="form-group">
                    <label>熟悉UML程度 Familiar with UP(Weight:1.5)</label>
                    <select
                      name="F1"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F1"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>开发应用程序的经验Application experience(Weight:0.5)</label>
                    <select
                      name="F2"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F2"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>面向对象的经验 OO experience(Weight:1)</label>
                    <select
                      name="F3"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F3"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>主分析师能力Lead analyst capability(Weight:0.5)</label>
                    <select
                      name="F4"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F4"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>激励机制 Motivation(Weight:1)</label>
                    <select
                      name="F5"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F5"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>需求稳定度 Stable requirements(Weight:2)</label>
                    <select
                      name="F6"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F6"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>具有兼职人员 Part-time workers(Weight:-1)</label>
                    <select
                      name="F7"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F7"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="form-group">
                    <label>具有复杂编程 Difficult programming(Weight:-1)</label>
                    <select
                      name="F8"
                      class="form-control form-control-solid form-control-lg"
                      v-model="F8"
                      @change="selectedItemChange($event)">
                    <option v-for="iitem in list"
                    :key="iitem.id"
                    :value="iitem.value">{{iitem.value}}</option>
                    </select>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div class="font-weight-bold mb-3">
                      EF:
                    </div>
                    <div class="line-height-md">
                      EFactor:{{calculateEFactor()}}
                      <br />
                      EF=1.4+(-0.03*EFactor)={{calculateEF()}}
                    </div>
                </div>
                <!--end: Wizard Step 4-->
  
                <!--begin: Wizard Step 5-->
                <div class="pb-5" data-wizard-type="step-content">
                  <h4 class="mb-10 font-weight-bold text-dark">
                    Calculate adjusted use case points                
                  </h4>
                  <div class="border-bottom mb-5 pb-5">
                    <div class="font-weight-bold mb-3">
                      UUCP:
                    </div>
                    <div class="line-height-md">
                      UAW:{{calculateUAW()}}
                      <br />
                      UUC:{{calculateUUC()}} <br />
                      UUCP=UAW+UUC={{calculateUAW()+calculateUUC()}}
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                    <div class="font-weight-bold mb-3">
                      TCF:
                    </div>
                    <div class="line-height-md">
                      TFactor:{{calculateTFactor()}}
                      <br />
                      TCF=0.6+(0.01*TFactor)={{calculateTCF()}} <br />
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                    <div class="font-weight-bold mb-3">
                      EF:
                    </div>
                    <div class="line-height-md">
                      EFactor:{{calculateEFactor()}}
                      <br />
                      EF:{{calculateEF()}}
                    </div>
                  </div>
                  <div class="mb-5">
                    <div class="font-weight-bold mb-3">
                      UPC:
                    </div>
                    <div class="line-height-md">
                      UPC = UUCP*TCF*EF={{(calculateUAW()+calculateUUC())*calculateEF()*calculateTCF()}}
                      <br />
                    </div>
                  </div>
                  <div class="border-bottom mb-5 pb-5">
                  </div>
                    <div style="margin-top: 2rem;margin-right: 2rem;margin-left: 2rem;">
                      <b-media>
                        <template v-slot:aside>
                          <!-- <b-img
                            src="media/stock-600x600/img-0.png"
                            width="50"
                          ></b-img> -->
                        </template>

                        <h5 class="mt-0">Analysis</h5>
                        <ul style="margin-left: 2rem;">
                          <li v-for="(item, index) in chatGPT.split('\n\n')" :key="index" style="margin-bottom: 0.8rem;">
                            {{ item }}
                          </li>
                        </ul>
                      </b-media>
                      </div>
                </div>
                <!--end: Wizard Step 5-->
  
                <!--begin: Wizard Actions -->
                <div class="d-flex justify-content-between border-top pt-10">
                  <div class="mr-2">
                    <button
                      class="btn btn-light-primary font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-prev"
                    >
                      Previous
                    </button>
                  </div>
                  <div>
                    <button
                      v-on:click="submit"
                      class="btn btn-success font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-submit"
                    >
                      Analyze
                    </button>
                    <button
                      class="btn btn-primary font-weight-bold text-uppercase px-9 py-4"
                      data-wizard-type="action-next"
                    >
                      Next Step
                    </button>
                  </div>
                </div>
                <!--end: Wizard Actions -->
              </form>
              <!--end: Wizard Form-->
            </div>
          </div>
          <!--end: Wizard Body-->
        </div>
        <!--end: Wizard-->
      </div>
    </div>
  </template>
  
  <style lang="scss">
  @import "@/assets/sass/pages/wizard/wizard-3.scss";
  </style>
  
  <script>
  import { SET_BREADCRUMB } from "@/core/services/store/breadcrumbs.module";
  import KTUtil from "@/assets/js/components/util";
  import KTWizard from "@/assets/js/components/wizard";
  import{ chatGPTAnalysis } from "@/api/uc.js";
  import Swal from "sweetalert2";
  
  let ActorNumber={"Complex":0,"Common":0,"Simple":0}
  let UseCaseNumber={"Complex":0,"Common":0,"Simple":0}
  
  export default {
    name: "uc",
    data() {
       return {
        item:[
          // {Type:"Complex",Actor:"Student",Weight:3},
          // {Type:"Complex",Actor:"Undergraduate",Weight:3},
          // {Type:"Common",Actor:"Payments subsystem",Weight:2},
          // {Type:"Simple",Actor:"Financial subsystem",Weight:1}
         ],
         item2:[
          // {Type:"Complex",Use_Case:"Course Selection",Weight:15},
          // {Type:"Common",Use_Case:"Enroll",Weight:10},
          // {Type:"Common",Use_Case:"Topics",Weight:10},
          // {Type:"Common",Use_Case:"Application for defense",Weight:10},
          // {Type:"Common",Use_Case:"Payment",Weight:10},
          // {Type:"Common",Use_Case:"Bank transfer",Weight:10},
          // {Type:"Simple",Use_Case:"Check class schedule",Weight:5},
          // {Type:"Simple",Use_Case:"Check grades",Weight:5},
          // {Type:"Simple",Use_Case:"Print transcript",Weight:5},
          // {Type:"Simple",Use_Case:"Check Payment",Weight:5}
         ],
         list:[
          {id:0,value:"0 means no impact"},
          {id:1,value:"1 means small impact"},
          {id:2,value:"2 means mild impact"},
          {id:3,value:"3 means moderate impact"},
          {id:4,value:"4 means significant impact"},
          {id:5,value:"5 means major impact"}
         ],
        T1:"0 means no impact",
        T2:"0 means no impact",
        T3:"0 means no impact",
        T4:"0 means no impact",
        T5:"0 means no impact",
        T6:"0 means no impact",
        T7:"0 means no impact",
        T8:"0 means no impact",
        T9:"0 means no impact",
        T10:"0 means no impact",
        T11:"0 means no impact",
        T12:"0 means no impact",
        T13:"0 means no impact",
        F1:"0 means no impact",
        F2:"0 means no impact",
        F3:"0 means no impact",
        F4:"0 means no impact",
        F5:"0 means no impact",
        F6:"0 means no impact",
        F7:"0 means no impact",
        F8:"0 means no impact",
        TWeight:[2,1,1,1,1,0.5,0.5,2,1,1,1,1,1],
        FWeight:[1.5,0.5,1,0.5,1,2,-1,-1],
        TFactor:0,
        TCF:0,
        EFactor:0,
        EF:0,
        file:null,
        file2:null,
        chatGPT : "AI分析还在进行中,请稍后。。。"
        }
        },
    mounted() {
      this.$store.dispatch(SET_BREADCRUMB, [
        { title: "用例点度量", route: "用例点度量" },
        { title: "用例点度量" }
      ]);
  
      // Initialize form wizard
      const wizard = new KTWizard("kt_wizard_v3", {
        startStep: 1, // initial active step number
        clickableSteps: true // allow step clicking
      });
  
      // Validation before going to next page
      wizard.on("beforeNext", function(/*wizardObj*/) {
        // validate the form and use below function to stop the wizard's step
        // wizardObj.stop();
      });
  
      // Change event
      wizard.on("change", function(/*wizardObj*/) {
        setTimeout(() => {
          KTUtil.scrollTop();
        }, 500);
      });
    },
    methods: {
      UCAnalyze(){
        let message = [{"UUCP":this.calculateUAW()+this.calculateUUC(),
                                "TCF":this.calculateTCF(),
                                "EF":this.calculateEF(),
                                 "UPC":(this.calculateUAW()+this.calculateUUC())*this.calculateTCF()*this.calculateEF()}
        ]
                let formData2 = new FormData()
                formData2.append('UCAResult', JSON.stringify(message))
                chatGPTAnalysis(formData2).then(resp => {
                    this.chatGPT = resp.data.MSG;
                })
      },
      submit: function(e) {
        this.UCAnalyze()
        e.preventDefault();
        Swal.fire({
          title: "",
          text: "The application has been successfully submitted!",
          icon: "success",
          confirmButtonClass: "btn btn-secondary"
        });
      },
      selectedItemChange: function(event){
        if(event.target.name == "T1"){this.T1 = event.target.value;}
        else if(event.target.name == "T2"){this.T2 = event.target.value;}
        else if(event.target.name == "T3"){this.T3 = event.target.value;}
        else if(event.target.name == "T4"){this.T4 = event.target.value;}
        else if(event.target.name == "T5"){this.T5 = event.target.value;}
        else if(event.target.name == "T6"){this.T6 = event.target.value;}
        else if(event.target.name == "T7"){this.T7 = event.target.value;}
        else if(event.target.name == "T8"){this.T8 = event.target.value;}
        else if(event.target.name == "T9"){this.T9 = event.target.value;}
        else if(event.target.name == "T10"){this.T10 = event.target.value;}
        else if(event.target.name == "T11"){this.T11 = event.target.value;}
        else if(event.target.name == "T12"){this.T12 = event.target.value;}
        else if(event.target.name == "F13"){this.F13 = event.target.value;}
      },
      calculateTFactor:function(){
        this.TFactor=0
        this.TFactor+=this.T1.substr(0,1)*this.TWeight[0]
        this.TFactor+=this.T2.substr(0,1)*this.TWeight[1]
        this.TFactor+=this.T3.substr(0,1)*this.TWeight[2]
        this.TFactor+=this.T4.substr(0,1)*this.TWeight[3]
        this.TFactor+=this.T5.substr(0,1)*this.TWeight[4]
        this.TFactor+=this.T6.substr(0,1)*this.TWeight[5]
        this.TFactor+=this.T7.substr(0,1)*this.TWeight[6]
        this.TFactor+=this.T8.substr(0,1)*this.TWeight[7]
        this.TFactor+=this.T9.substr(0,1)*this.TWeight[8]
        this.TFactor+=this.T10.substr(0,1)*this.TWeight[9]
        this.TFactor+=this.T11.substr(0,1)*this.TWeight[10]
        this.TFactor+=this.T12.substr(0,1)*this.TWeight[11]
        this.TFactor+=this.T13.substr(0,1)*this.TWeight[12]
        return this.TFactor
      },
      calculateTCF:function(){
        this.TCF = this.TFactor*0.01+0.6
        return this.TCF
      },
      calculateEFactor:function(){
        this.EFactor=0
        this.EFactor+=this.F1.substr(0,1)*this.FWeight[0]
        this.EFactor+=this.F2.substr(0,1)*this.FWeight[1]
        this.EFactor+=this.F3.substr(0,1)*this.FWeight[2]
        this.EFactor+=this.F4.substr(0,1)*this.FWeight[3]
        this.EFactor+=this.F5.substr(0,1)*this.FWeight[4]
        this.EFactor+=this.F6.substr(0,1)*this.FWeight[5]
        this.EFactor+=this.F7.substr(0,1)*this.FWeight[6]
        this.EFactor+=this.F8.substr(0,1)*this.FWeight[7]
        return this.EFactor
      },
      calculateEF:function(){
        this.EF = (-0.03*this.EFactor)+1.4
        return this.EF
      },
      getUploadUrl: function(flie) {
       let url = "";
       if (window.createObjectURL != undefined) {
          url = window.createObjectURL(flie);
      } else if (window.webkitURL != undefined) {
          url = window.webkitURL.createObjectURL(flie);
      } else if (window.URL != undefined) {
          url = window.URL.createObjectURL(flie);
      }
      return url; 
     },
      loadXML: function(xmlFile) {
      var xmlDom = null;
      if (
          document.implementation &&
          document.implementation.createDocument
      ) {
          var xmlhttp = new window.XMLHttpRequest();
          xmlhttp.open("GET", xmlFile, false);
          xmlhttp.send(null);
          xmlDom = xmlhttp.responseXML;
      } else {
          xmlDom = null;
      }
      return xmlDom; 
     },
     OnShow(){
        this.item=[]
  
        let url = this.getUploadUrl(this.file); // 文件对象
        let xml = this.loadXML(url);
        let text = new XMLSerializer().serializeToString(xml) // 将text赋值给textarea阔以了
        console.log(text)
        let domParser = new DOMParser();
        let xmlDoc = domParser.parseFromString(text,'text/xml');
        console.log(xmlDoc);
        let elements = xmlDoc.getElementsByTagName("record");
        console.log(elements[0])
        for(var i=0;i<elements.length;i++){
            var b =elements[i].getElementsByTagName("Type")
            var c =elements[i].getElementsByTagName("Actor")
            var d =elements[i].getElementsByTagName("Weight")
            var temp ={}
            temp["Type"] = b[0].innerHTML
            temp["Actor"] = c[0].innerHTML
            temp["Weight"] = d[0].innerHTML
            this.item.push(temp)
        }
      },
      OnShow2(){
        this.item2=[]
  
        let url = this.getUploadUrl(this.file2); // 文件对象
        let xml = this.loadXML(url);
        let text = new XMLSerializer().serializeToString(xml) // 将text赋值给textarea阔以了
        console.log(text)
        let domParser = new DOMParser();
        let xmlDoc = domParser.parseFromString(text,'text/xml');
        console.log(xmlDoc);
        let elements = xmlDoc.getElementsByTagName("record");
        console.log(elements[0])
        for(var i=0;i<elements.length;i++){
            var b =elements[i].getElementsByTagName("Type")
            var c =elements[i].getElementsByTagName("Use_Case")
            var d =elements[i].getElementsByTagName("Weight")
            var temp ={}
            temp["Type"] = b[0].innerHTML
            temp["Use_Case"] = c[0].innerHTML
            temp["Weight"] = d[0].innerHTML
            this.item2.push(temp)
        }
      },
      AccountForActorNumber: function(){
         ActorNumber={"Complex":0,"Common":0,"Simple":0}
        for(var i=0;i<this.item.length;i++){
          if(this.item[i].Type == "Complex"){ActorNumber["Complex"]++}
          if(this.item[i].Type == "Common"){ActorNumber["Common"]++}
          if(this.item[i].Type == "Simple"){ActorNumber["Simple"]++}
        }
        return ActorNumber
      },
      AccountForUseCaseNumber: function(){
         UseCaseNumber={"Complex":0,"Common":0,"Simple":0}
        for(var i=0;i<this.item2.length;i++){
          if(this.item2[i].Type == "Complex"){UseCaseNumber["Complex"]++}
          if(this.item2[i].Type == "Common"){UseCaseNumber["Common"]++}
          if(this.item2[i].Type == "Simple"){UseCaseNumber["Simple"]++}
        }
        return UseCaseNumber
    },
    calculateUAW:function(){
      return 3*ActorNumber.Complex+2*ActorNumber.Common+1*ActorNumber.Simple
    },
    calculateUUC:function(){
      return 15*UseCaseNumber.Complex+10*UseCaseNumber.Common+5*UseCaseNumber.Simple
    }
    },
  };
  </script>
  